#include <rclcpp/rclcpp.hpp>
#include <geometry_msgs/msg/point_stamped.hpp>

class ClickListener : public rclcpp::Node {
public:
    ClickListener() : Node("click_listener") {
        subscription_ = this->create_subscription<geometry_msgs::msg::PointStamped>(
            "/clicked_point", 10, std::bind(&ClickListener::listener_callback, this, std::placeholders::_1));
    }

private:
    void listener_callback(const geometry_msgs::msg::PointStamped::SharedPtr msg) {
        double x = msg->point.x;
        double y = msg->point.y;
        double z = msg->point.z;
        RCLCPP_INFO(this->get_logger(), "Clicked at: (%f, %f, %f)", x, y, z);
        // (2.124116, -3.035008, 0.002472)
    }

    rclcpp::Subscription<geometry_msgs::msg::PointStamped>::SharedPtr subscription_;
};

int main(int argc, char * argv[]) {
    rclcpp::init(argc, argv);
    rclcpp::spin(std::make_shared<ClickListener>());
    rclcpp::shutdown();
    return 0;
}